package com.google.mr.okhttptest;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.google.mr.okhttptest.utils.ActivityManagerUtils;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/11/24.
 */

public abstract class BaseActivity extends AppCompatActivity {

    private Unbinder unbinder;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initFeature();
        setContentView(layoutId());
        unbinder = ButterKnife.bind(this);
        initView();
        initListener();
        initData();
        ActivityManagerUtils.addActivity(this);
    }

    protected abstract void initFeature();

    protected abstract int layoutId();

    protected abstract void initView();

    protected abstract void initListener();

    protected abstract void initData();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
        ActivityManagerUtils.removeActivity(this);
    }
}
